package com.gaga.metadata.common.enums;

/**
 * 列修改类型
 * ColumnUpdateType
 **/
public enum ColumnUpdateType {

    NAME("name", "修改列名称", "code", false, false),

    DBTYPE("dbType", "修改列类型", "columnType", true, false),

    COMMENT("comment", "修改列描述", "columnName", false, false),

    KEYFLAG("keyFlag", "修改列主键", "code", true, false),

    ISNULLABLE("isNullable", "修改列是否允许为空", "notNull", true, false),

    PRECISION("precision", "修改列长度", "columnSize", true, true),

    SCALE("scale", "修改列小数位", "columnAccuracy", true, true);

    private String code;
    private String desc;
    /**
     * 映射的字段
     */
    private String modelColumnMapper;
    /**
     * 是否需要验证数据
     */
    private Boolean needValidateData;

    private Boolean impactAnalysis;

    ColumnUpdateType(String code, String desc, String modelColumnMapper, Boolean needValidateData, Boolean impactAnalysis) {
        this.code = code;
        this.desc = desc;
        this.modelColumnMapper = modelColumnMapper;
        this.needValidateData = needValidateData;
        this.impactAnalysis = impactAnalysis;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public String getModelColumnMapper() {
        return modelColumnMapper;
    }

    public Boolean getNeedValidateData() {
        return needValidateData;
    }

    public Boolean getImpactAnalysis() {
        return impactAnalysis;
    }

    public static ColumnUpdateType ofCode(String modelColumnMapper) {
        for (ColumnUpdateType dbType : values()) {
            if (dbType.modelColumnMapper.equalsIgnoreCase(modelColumnMapper)) {
                return dbType;
            }
        }
        return null;
    }

}
